﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;
namespace GUI
{
    public partial class FormThemBanAn : Form
    {
        public FormThemBanAn()
        {
            InitializeComponent();
            KhuVucBUS kvBUS = new KhuVucBUS();
            List<KhuVucDTO> listKhuVuc = kvBUS.LayDanhSachKhuVuc();
            ccbChonKhuVuc.DataSource = listKhuVuc;
            ccbChonKhuVuc.DisplayMember = "Ten_Khu_Vuc";
            ccbChonKhuVuc.ValueMember = "Id_Khu_Vuc";
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnXemDanhSachBanAn_Click(object sender, EventArgs e)
        {
            FormDanhSachBanAn frm = new FormDanhSachBanAn();
            frm.Show();
        }
        int STT = 0;
        private void btnThem_Click(object sender, EventArgs e)
        {
            if(txtSoLuong.Text =="")
            {
                MessageBox.Show("Vui Lòng Nhập Tên Bàn!");
                return;
            }
            BanAnDTO banAn = new BanAnDTO();
            banAn.Ten_Ban_An = txtSoLuong.Text;
            banAn.Id_Khu_Vuc = Convert.ToInt32(ccbChonKhuVuc.SelectedValue);
            BanAnBUS banAnBUS = new BanAnBUS();
            int kq = banAnBUS.ThemBanAn(banAn);
            if (kq > 0)
            {
                MessageBox.Show("Thêm Bàn Ăn Thành Công!");
                gridViewThemBanAn.Rows.Add(STT, banAn.Ten_Ban_An, banAn.Id_Khu_Vuc);
                STT++;
            }
            else
            {
                MessageBox.Show("Bàn Ăn Này Đã Có Rồi, Vui Lòng Nhập Bàn Ăn Khác!");
            }
            
        }

        private void ccbChonKhuVuc_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        private void txtSoLuong_TextChanged(object sender, EventArgs e)
        {

        }

        private void gridViewThemBanAn_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
